{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# {cpp:func}`tvm::relay::RewriteAnnotatedOps`\n",
    "\n",
    "源码：`tvm/include/tvm/relay/transform.h`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```c++\n",
    "/*!\n",
    " * \\brief Rewrite the annotated program.\n",
    " *\n",
    " * \\param expr The expression.\n",
    " * \\param fallback_device The fallback device which is the default device for\n",
    " *                        operators without annotation.\n",
    " *\n",
    " * \\return The updated program.\n",
    " */\n",
    "TVM_DLL Expr RewriteAnnotatedOps(const Expr& expr, int fallback_device);\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`RewriteAnnotatedOps` 函数，它接受两个参数：\n",
    "\n",
    "1. `expr`：一个表达式。\n",
    "2. `fallback_device`：一个整数，表示默认设备，用于没有注解的算子。\n",
    "\n",
    "函数的主要功能是重写带有注解的程序。它返回更新后的程序。\n",
    "\n",
    "具体来说，这个函数的作用是将带有注解的算子重写为在指定的设备上执行。如果没有指定设备，则使用默认设备。这个函数可以用于优化程序的性能，例如将某些算子移动到 GPU 上执行以加速计算。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
